﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using foodandgo.Helper;
using foodandgo.Models;
using foodandgo.ViewModels;
using AttributeRouting.Web.Mvc;

namespace foodandgo.Controllers
{
    public class PlaceController : Controller
    {
        //
        // GET: /DiaDiem/

        public ActionResult Index()
        {
            return View();
        }

        [GET("dia-diem/{id}/{name}")]
        public ActionResult Detail(int id, string name)
        {
            var placeDetail = new PlaceDetail();
            using (var db = new Db())
            {
                placeDetail.Place = db.Places.FirstOrDefault(x => x.PlaceId == 6);
                placeDetail.Review = db.Reviews.ToList();
            }

            if (name != placeDetail.Place.Name.SeoName())
                return RedirectToActionPermanent("Detail", new {id=id, name = placeDetail.Place.Name.SeoName() });
            return View(placeDetail);
        }
        
    }
}
